package com.example.autooperation.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.autooperation.entity.Log;
import com.example.autooperation.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/log")
public class LogController {

    @Autowired
    private LogService logService;

    @GetMapping
    public List<Log> getLogsByTaskId(@RequestParam int taskId) {
        QueryWrapper<Log> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("task_id", taskId).orderByAsc("timestamp");
        return logService.list(queryWrapper);
    }
} 